package com.su.sweet.socket;

import org.noear.solon.annotation.Component;
import org.noear.solon.core.bean.LifecycleBean;
import org.smartboot.socket.transport.AioQuickServer;

@Component
public class TcpServer implements LifecycleBean {
    private AioQuickServer server;

    @Override
    public void start() throws Throwable {
        server = new AioQuickServer(8888, new DecoderProtocolImpl(), new MessageProcessorImpl());
        server.start();
    }

    @Override
    public void stop() throws Throwable {
        if (server != null) {
            server.shutdown();
        }
    }
}
